<?php
import('@.ORG.Util.Page'); // 导入分页类

// 本类由系统自动生成，仅供测试用途
class VmovieAction extends BaseAction {
	public function index() {
		header("Content-Type:text/html; charset=utf-8");
		$Event = D('ny_vmovie'); // 实例化User对象
		
		$count = $Event->count(); // 查询满足要求的总记录数
		$Page = new Page($count, 10); // 实例化分页类 传入总记录数和每页显示的记录数
		$show = $Page->show(); // 分页显示输出
		// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$list = $Event->order('createDate desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
		$this->assign('list', $list); // 赋值数据集
		$this->assign('page', $show); // 赋值分页输出
		$this->display();
	}
	
	public function toAddVmovie(){
		$this->redirect('editVmovie');
		$this->display();
	}
	
	public function deploy(){
		$id = $_REQUEST['id'];
		$data['state']=1;
		$model = D("ny_event");
		$model->where("id=".$id)->save($data);
	}
	
	public function delEvent(){
		$id = $_REQUEST['id'];
		$model = D('ny_event');
		$data['state']=2;
		$model->where("id=".$id)->save($data);
		echo 1;
	}
	
	public function saveVmovie(){
		$data['remarks'] = htmlspecialchars($_REQUEST['remarks']);
		$data['title'] = htmlspecialchars($_REQUEST['title']);
		$data['keys'] = htmlspecialchars($_REQUEST['keys']);
		$data['url'] = htmlspecialchars($_REQUEST['url']);
		$data['id'] = $_REQUEST['id'];
		$model = D("ny_vmovie");
		if(empty($data['id'])){
			$data['id'] = $model->add($data);
		}else{
			$model->save($data);
		}
		
		
		$this->redirect('editVmovie', array('id'=>$data['id']));
	}
	
	public function editVmovie(){
		$model = D("ny_vmovie");
		$id = $_REQUEST['id'];
		$data = $model->where("id=".$id)->find();
		
		$this->assign("id",$id);
		$this->assign("data",$data);
		$this->display();
	}
	
	
	
	public function delVmovie(){
		$model = D("ny_vmovie");
		$model->where("id=".$_REQUEST['id'])->delete();
		echo 1;
	}
}